import request from "@/utils/request";
import { API_ENDPOINTS } from "@/config/api";

// 社交能量站内容接口
export interface SocialEnergyContent {
  id: number;
  title: string;
  content: string;
  content_type: "tip" | "quote" | "exercise" | "article";
  is_active: boolean;
  created_at: string;
}

// 通知接口
export interface UserNotification {
  id: number;
  user_id: number;
  title: string;
  content: string;
  type: "achievement" | "challenge" | "system" | "social";
  is_read: boolean;
  read_at?: string;
  created_at: string;
}

// 用户段位接口
export interface UserTier {
  id: number;
  user_id: number;
  current_tier: "bronze" | "silver" | "gold" | "platinum" | "diamond";
  tier_points: number;
  created_at: string;
}

// 内容举报参数
export interface ContentReportParams {
  content_type: "share" | "comment" | "help_request" | "help_answer";
  content_id: number;
  reason: "spam" | "inappropriate" | "harassment" | "other";
  description?: string;
}

// 其他功能API
export const miscApi = {
  // 获取社交能量站内容
  getSocialEnergyContent(params?: { content_type?: string; page?: number }) {
    return request.get<SocialEnergyContent[]>(API_ENDPOINTS.SOCIAL_ENERGY, {
      params,
    });
  },

  // 获取通知列表
  getNotifications(
    userId: number,
    params?: {
      page?: number;
    }
  ) {
    return request.get<UserNotification[]>(
      API_ENDPOINTS.NOTIFICATIONS(userId),
      { params }
    );
  },

  // 标记通知已读
  markNotificationRead(notificationId: number) {
    return request.put(API_ENDPOINTS.MARK_NOTIFICATION_READ(notificationId));
  },

  // 获取用户段位
  getUserTier(userId: number) {
    return request.get<UserTier>(API_ENDPOINTS.USER_TIER(userId));
  },

  // 尝试升级段位
  upgradeTier(userId: number) {
    return request.post(API_ENDPOINTS.TIER_UPGRADE(userId));
  },

  // 举报内容
  reportContent(params: ContentReportParams) {
    return request.post(API_ENDPOINTS.CONTENT_REPORT, params);
  },
};
